//
//  CC_SpecialColumn_CollectionViewCell.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_SpecialColumn_CollectionViewCell.h"
#import "CCBaseMainTitleLabel.h"
#import "CCBaseSubHeadLabel.h"

#import "CCBaseImageView.h"

#import "CC_SpecialColumn_Model.h"

@interface CC_SpecialColumn_CollectionViewCell ()

@property(nonatomic, retain)CCBaseImageView *imageView;
@property(nonatomic, retain) CCBaseMainTitleLabel *mainTitleLabel;
@property(nonatomic, retain) CCBaseSubHeadLabel *subHeadLabel;
@property(nonatomic, retain) CCBaseSubHeadLabel *subTitleLabel;



@property(nonatomic, retain) CCBaseImageView *headerImage;  // 小人头像
@property(nonatomic, retain) CCBaseImageView *littleCircle;  // 圆圈图片
@property(nonatomic, retain) CCBaseImageView *arrowImage;  // 箭头图片

@end


@implementation CC_SpecialColumn_CollectionViewCell

- (void)dealloc
{
    [_specialModel release];
    
    [_headerImage release];
    [_littleCircle release];
    [_arrowImage release];
  
    [_imageView release];
    [_mainTitleLabel release];
    [_subHeadLabel release];
    [_subTitleLabel release];
    
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.imageView = [[CCBaseImageView alloc]init];
//                self.imageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageView];
        [_imageView release];
        
        self.mainTitleLabel = [[CCBaseMainTitleLabel alloc]init];
//                self.mainTitleLabel.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_mainTitleLabel];
        [_mainTitleLabel release];
        
        
        self.headerImage = [[CCBaseImageView alloc]init];
        self.headerImage.image = [UIImage imageNamed:@"member_num@2x.png"];
        [self.contentView addSubview:_headerImage];
        [_headerImage release];
        
         self.subHeadLabel = [[CCBaseSubHeadLabel alloc]init];
//                self.subHeadLabel.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:_subHeadLabel];
        [_subHeadLabel release];

         self.arrowImage = [[CCBaseImageView alloc]init];
        self.arrowImage.image = [UIImage imageNamed:@"np_loverview_arraw@2x.png"];
        [self.contentView addSubview:_arrowImage];
        [_arrowImage release];
        

        self.littleCircle = [[CCBaseImageView alloc]init];
        self.littleCircle.image = [UIImage imageNamed:@"netsound_del@2x.png"];
        [self.contentView addSubview:_littleCircle];
        [_littleCircle release];
        
        self.subTitleLabel = [[CCBaseSubHeadLabel alloc]init];
//        self.subTitleLabel.backgroundColor = [UIColor greenColor];
        self.subTitleLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_subTitleLabel];
        [_subTitleLabel release];
        
       

               
    }
    return self;
}

-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    // item size
//   return CGSizeMake( SCREENWIDTH - 2 * SPACED  , (SCREENWIDTH - 6 * SPACED) / 3 );
    
    
    self.imageView.frame = CGRectMake(0, 0, (SCREENWIDTH - 2 * SPACED) * 0.2 , (SCREENWIDTH - 6 * SPACED) / 3 - SPACED * 2);
    
    [self.mainTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(_imageView.frame.size.width * 3, _imageView.frame.size.height * 0.25));
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.left.equalTo(self.imageView.mas_right).offset(SPACED);
//        make.left.equalTo(self.contentView.mas_left).offset(0);
        
    }];
    
    
    
    //  小人头像大小
    [self.headerImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SPACED * 1.5, SPACED * 1.5));
        make.top.equalTo(self.mainTitleLabel.mas_bottom).offset(SPACED * 0.8);
        make.left.equalTo(self.imageView.mas_right).offset(SPACED);
    }];
    
    
    [self.subHeadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(_imageView.frame.size.width * 3 - 2 * SPACED, SPACED * 2));
        
        make.top.equalTo(self.mainTitleLabel.mas_bottom).offset(SPACED * 0.8);
        make.left.equalTo(self.headerImage.mas_right).offset(SPACED / 4);

    }];
    
    
    [self.arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED));
        make.right.equalTo(self.contentView.mas_right).offset(-SPACED);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-SPACED * 4);
        
    }];
    

    
    [self.littleCircle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SPACED * 1.5, SPACED * 1.5));
        make.left.equalTo(self.imageView.mas_right).offset(SPACED);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-SPACED * 2);
        
    }];
    
          [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
              make.size.mas_equalTo(CGSizeMake(SPACED * 12, SPACED * 1.5));
              make.bottom.equalTo(self.contentView.mas_bottom).offset(-SPACED * 2);
              make.left.equalTo(self.littleCircle.mas_right).offset(SPACED * 0.8);
          }];
        

}


-(void)setSpecialModel:(CC_SpecialColumn_Model *)specialModel{
    
    if (_specialModel != specialModel) {
        [_specialModel release];
        _specialModel = [specialModel retain];
    }
    
    [self.imageView setImageWithURL:[NSURL URLWithString:specialModel.coverPath]];
    self.mainTitleLabel.text = specialModel.title;
    self.subHeadLabel.text = specialModel.subtitle;
    self.subTitleLabel.text = specialModel.footnote;
    
}

@end
